# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Douglas Soares de Andrade <dsandrade@gmail.com>
# Contributor: William Rea <sillywilly@gmail.com>

pkgname=python-bsddb
_pkgname=bsddb3
pkgver=6.2.9
pkgrel=5
pkgdesc='Python interface for BerkeleyDB'
arch=('loong64' 'x86_64')
url='https://www.jcea.es/programacion/pybsddb.htm'
license=('BSD')
depends=('db' 'python')
source=(https://files.pythonhosted.org/packages/source/b/$_pkgname/$_pkgname-$pkgver.tar.gz)
sha256sums=('70d05ec8dc568f42e70fc919a442e0daadc2a905a1cfb7ca77f549d49d6e7801')

prepare() {
  cd $_pkgname-$pkgver
  sed -i 's/YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION/LINKING_IS_NOT_A_DERIVATIVE_WORK/g' setup3.py test3.py
}

build() {
  cd $_pkgname-$pkgver
  LINKING_IS_NOT_A_DERIVATIVE_WORK=1 python3 setup.py --berkeley-db=/usr build
}

package() {
  cd $_pkgname-$pkgver
  LINKING_IS_NOT_A_DERIVATIVE_WORK=1 python3 setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
}
